﻿/*****************************************************************************************************************
* This code is taken from http://mr-sharpoblunto.junkship.org/2008/07/silverlight-one-step-forward-one-step.html *
*TODO: We must re write this class                                                                               *
 *****************************************************************************************************************/

using System;
using System.Configuration;

//This module acts like a parser for site config file
namespace SoapProxyComponent

{
    public class SoapProxyConfiguration : ConfigurationSection
    {
        [ConfigurationProperty("endPointMappings")]
        public MappingsCollection EndPointMappings
        {
            get
            { return (MappingsCollection)this["endPointMappings"]; }
            set
            { this["endPointMappings"] = value; }
        }
    }

    public sealed class MappingsCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new MappingElement();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((MappingElement)element).ProxyEndPoint;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
        protected override string ElementName
        {
            get
            {
                return "mapping";
            }
        }
    }

    public class MappingElement : ConfigurationElement
    {
        [ConfigurationProperty("remoteEndPoint", IsRequired = true)]
        public String RemoteEndPoint
        {
            get
            { return (String)this["remoteEndPoint"]; }
            set
            { this["remoteEndPoint"] = value; }
        }

        [ConfigurationProperty("proxyEndPoint", IsRequired = true)]
        public String ProxyEndPoint
        {
            get
            { return (String)this["proxyEndPoint"]; }
            set
            { this["proxyEndPoint"] = value; }
        }
    }

}
